Skip to content

Add new C37.118 Synchrophasor node-type (reloaded) - #1023

Open
pjungkamp wants to merge 4 commits into
masterfrom
node-c37.118
Open

Add new C37.118 Synchrophasor node-type (reloaded)#1023
pjungkamp wants to merge 4 commits into
masterfrom
node-c37.118

Conversation

@pjungkamp

Copy link
Copy Markdown
Contributor

Description

New comprehensive node type implementing the C37.118.2-2011 protocol over TCP acting as both client and server. It features near zero-configuration for the client-side and a relatively simple configuration for the server-side.

{
  "nodes": {
    "c37_118": {
      "type": "c37.118",

      "in": {
        "address": "localhost",
        "idcode": 48879
      },

      "out": {
        "address": "localhost",
        "idcode": 48879,
        "data_rate": 10,
        "pmus": [
          {
            "name": "VILLASnode",
            "idcode": 48879,
            "frequency": "frequency_signal0",
            "rocof": "rocof_signal0",
            "phasor": [
              {
                "signal": "phasor_signal0",
                "unit": "volt"
              },
              {
                "signal": "phasor_signal1",
                "unit": "volt"
              },
              {
                "signal": "phasor_signal2",
                "unit": "volt"
              }
            ]
          }
        ]
      }
    }
  }
}

Unimplemented

  • Request configuration 3 messages when available
  • Multiple data streams on the same server.
  • Detect runtime configuration changes
  • Client reconnection on server-side disconnect (depends on configuration change detection)
  • TLS encryption
  • UDP transport

Mentions

Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
@pjungkamp
pjungkamp marked this pull request as ready for review July 29, 2026 06:53
@pjungkamp
pjungkamp requested review from n-eiling and stv0g as code owners July 29, 2026 06:53
@al3xa23
al3xa23 self-requested a review July 29, 2026 07:15
Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
Comment thread lib/nodes/c37_118.cpp
}

template <typename T, std::size_t shift, std::size_t mask>
class bit_field_proxy {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class defintion in header?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't add classes to headers that don't have to be shared. The header only exists to allow the unit test to verify the protocol implementation.

Comment thread lib/nodes/c37_118.cpp

bool C37Node::recvAll(int sd, std::span<std::byte> buf) {
std::size_t offset = 0;
while (offset < buf.size()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a maximal buffer size allowed in c37?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 65535 bytes, why?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it needs to be checked ... But it is quite large, so probably not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is essentially unrelated to C37. You give it a mutable span of bytes and recvAll fills that entire span with data. The C37 buffer size isn't part of this function's contract.

@al3xa23

al3xa23 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Nice impelementation, thanks :)
Some general questions:
Do you plan to do integration test?
Are you already preparing the documentation?

Comment thread common/lib/json.cpp
}

if (paths.empty()) {
*error = "include directive did not match any file";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I did not see it, but is the error somewhere logged for the user?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This function is a callback for a C library and thus is not allowed to throw any exceptions. The error here is later read from config_error_text if config_read failed.

@pjungkamp

Copy link
Copy Markdown
Contributor Author

Yes. Documentation is ready, I just didn't open a PR yet. I'm definitely missing an integration test though. I'll add one when I'm back.

@stv0g stv0g changed the title C37.118 Synchrophasor Node Reloaded Add C37.118 Synchrophasor node-type (reloaded) Jul 29, 2026
@stv0g stv0g added node::c37_118 enhancement New feature or request labels Jul 29, 2026
@stv0g stv0g changed the title Add C37.118 Synchrophasor node-type (reloaded) Add new C37.118 Synchrophasor node-type (reloaded) Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request node::c37_118

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add C37.118 node-type

3 participants